package contest.co6148;

import java.util.Map;

public class Solution {
    int[][] grid;
    public int[][] largestLocal(int[][] grid) {
        int[][] res=new int[grid.length-2][grid.length-2];
        this.grid=grid;
        for (int i = 1; i < grid.length-1; i++) {
            for (int j = 1; j < grid[0].length-1 ; j++) {
                res[i-1][j-1]=findMax(i,j);
            }
        }

        return res;
    }
    public int findMax(int i,int j){
        int max=grid[i][j];
        int[] row=new int[]{i-1,i-1,i-1,i,i,i+1,i+1,i+1};
        int[] col=new int[]{j-1,j,j+1,j-1,j+1,j-1,j,j+1};
        for (int k = 0; k < row.length; k++) {
            max= Math.max(max,grid[row[k]][col[k]]);
        }
        return max;
    }
}